import cv2

gray = cv2.imread(r"D:\data\CUGW\test4.bak\g2\IMG_5355.JPG",0)
#gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.blur(gray,(3,3))#不blur也可以，blur效果更好些

#ret, bw = cv2.threshold(gray, 179, 255, cv2.THRESH_BINARY)
ret, bw = cv2.threshold(gray, 150, 255, cv2.THRESH_BINARY)

cv2.imwrite(r"D:\data\CUGW\test4.bak\g2bw\IMG_5355.JPG", bw)